package cn.changeforyou.web.cloud.blog.service.impl;

import cn.changeforyou.web.cloud.webBase.common.model.PageQueryModel;
import cn.changeforyou.web.cloud.blog.entity.dto.ArticleDTO;
import cn.changeforyou.web.cloud.blog.entity.po.Article;
import cn.changeforyou.web.cloud.blog.mapper.ArticleMapper;
import cn.changeforyou.web.cloud.blog.model.ArticleModel;
import cn.changeforyou.web.cloud.blog.service.ArticleService;
import cn.changeforyou.web.plugin.page.MybatisPlusPageUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *
 */
@Service
public class ArticleServiceImpl extends ServiceImpl<ArticleMapper, Article>
    implements ArticleService{

    @Override
    public List<String> getTags() {
        return getBaseMapper().getTags();
    }

    @Override
    public Page<Article> getArticlePage(PageQueryModel<ArticleModel> pageQueryModel) {
        Page<Article> pageInfo = MybatisPlusPageUtil.getPageInfo(this.getClass());
        return this.page(pageInfo);
    }

    @Override
    public Article addOrUpdate(ArticleDTO article) {
        Article old = this.getOne(new LambdaQueryWrapper<Article>().eq(Article::getArticleName, article.getArticleName()));
        
        return null;
    }

    public boolean saveOrUpdate(Article article) {

        return true;
    }
}




